import consul


class MyConsul:

    def __init__(self, **kwargs):
        self.consul = None
        if kwargs:
            self.init(**kwargs)

    def init(self, **kwargs):
        self.consul = consul.Consul(**kwargs)

    def kv_get(self, k):
        return self.consul.kv.get(k)

    def kv_put(self, k, v, **kwargs):
        return self.consul.kv.put(k, v, **kwargs)


my_consul = MyConsul()


if __name__ == '__main__':
    my_consul.init(host='192.168.101.79')

    def test_kv():
        a = my_consul.consul.kv.put('aa', '1')
        b = my_consul.consul.kv.get('aa')
        print(a, b)

    test_kv()
